﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
namespace WindowsGame4
{
    public class Projectile : GameObject
    {
        public enum HitType{Player, Enemy, All};
        public bool bDieOnHit;
        public float damage;
        public HitType hit;
        public Projectile()
            : base()
        {
            texture = GameManager.bullet;
            bDieOnHit = true;
            hit = HitType.All;
            lifeTime = 5;
            bOntimer = true;
            damage = 0;
        }
        public override void React(GameObject obj, Vector2 cp)
        {
            base.React(obj, cp);
            if (obj is Damageable)
            {
                Damageable d = (Damageable)obj;
                if (obj is Player && hit == HitType.Enemy
                    || !(obj is Player) && hit == HitType.Player)
                    return;
                d.TakeDamage(damage);
                if (bDieOnHit)
                    bDead = true;
            }
        }
    }
}
